import paho.mqtt.client as mqtt
 
HOST = "douzi.wiki"
PORT = 1883
 
 
def on_message_callback(client, userdata, message):
 
    print(message.topic+" " + ":" + str(message.payload))
 
def on_connect(client, userdata, flags, rc):
    print("Connected with result code "+str(rc))
    client.subscribe("chanel_01")
 
def main():
    client = mqtt.Client('test')
    client.connect(HOST, PORT, 60)
    client.on_connect = on_connect
    client.publish("chanel_01", "666666666", 1)
    client.on_message = on_message_callback
    client.loop_forever()
 
 
if __name__ == '__main__':
    main()